package io;

import java.io.*;

public class io_api {
	public static void main (String[] args) {
		
		try {
			/* as of Java 5 */
			File file1 = new File("fileWriter3.txt");	//create a File obj
			PrintWriter pw1 = new PrintWriter(file1);	//pass file to the PrintWriter constructor
			pw1.println("howdy");	
			pw1.println("folks");
			pw1.flush();
			pw1.close();	
			
			/* Java 1.4 */
			File file2 = new File("fileWriter4.txt");	//create a File obj
			FileWriter fw = new FileWriter(file2);	//create a FileWriter that will send its output to a File
			PrintWriter pw2 = new PrintWriter(fw);
			pw2.println("howdy");	
			pw2.println("folks");
			pw2.flush();
			pw2.close();			
			
			File file3 = new File("fileWriter4.txt");	//create a File obj AND open "fileWriter4.txt"
			FileReader fr = new FileReader(file3);	//create a FileReader to get data from "file"
			BufferedReader br = new BufferedReader(fr);	//create a BufferReader to get its data from a Reader
			String data = br.readLine();	//read some data
			br.close();
		} catch (IOException e) {}
	}
}
